ioemu: Fix bug in map cache
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 9 Sep 2008 14:05:58 +0000 (15:05 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 9 Sep 2008 14:05:58 +0000 (15:05 +0100)
commit93bce41b7709fd95eb3f4eecee3108f48cf356c1
tree37b03fa3ded959277cec2f232b705f9c6b574512
parent8a64d79e8dc38fb7122f1822482427e4315957c9
ioemu: Fix bug in map cache

This small patch fixes an issue leading to a crash (segfault, although
with earlier changesets I was seeing sigbus - not sure what changed)
in qemu-dm when the following conditions occur:

1. A valid mapping for a bucket on a low address exists

2. Immediately after accessing memory mapped in this bucket, an access
occurs to a high (beyond assigned ram) address beyond the 1GB limit
for 32bit map cache wrapping around to the previous bucket's entry
number.

3. The next call to map cache again accesses the low address.

In this scenario, the guest mem for the low bucket has been unmapped
by the remap_bucket caused by 2., but because the valid_mapping
bit-test fails, map_cache returns before last_address_index has been
updated. The subsequent call to map_cache therefore never remaps the
low, valid bucket and instead returns a vaddr pointing to memory that
has failed to get mapped.

Signed-off-by: Trolle Selander <trolle.selander@eu.citrix.com>
tools/ioemu/hw/xen_machine_fv.c